import requests

from APIs.baseAPI import BaseAPI

from common.config import ip


class LoginAPI(BaseAPI):
    def login(self,data):
        url = f'{ip}/login'
        # data = {'username': uname, 'password': pwd}
        r = requests.post(url, data)
        self.login_json=r.json()
        if r.json()['code']==0:
            token=r.json()['Admin-Token']
            return token

    def login_result(self):
        return self.login_json['code']


if __name__ == '__main__':
    from APIs.logAPI import *
    a=LoginAPI()
    b=a.login({'username':'admin','password':'123456'})
    xx=LogAPI(b)
    xx.checkall()

    # xxx=xx.uploadFile()
    # sch=xx.upload(xxx)
    # cx=xx.check()
    # gx=xx.update(xxx,cx)
    # sc=xx.delete(cx)